package org.format;

import java.util.Date;

public class PrintfDemo {
    public static void main(String[] args) {
        System.out.printf("%tF %<tT %<tB %<tb %<tA %<ta %<tp %n", System.currentTimeMillis());
        //字符串格式化 String.format();格式化返回字符串   System.out.printf();格式化输出

        //<   1$
        String birth = String.format("%tY年%<tm月%<td日 %6$tA", System.currentTimeMillis(), 0, 0, 0, 0, 0L);
        System.out.println(birth);

        int num = 15;
        System.out.printf("%d %<02d %<03d %<04d %<05d%n", num);

        System.out.printf("%,d%n", Long.MAX_VALUE);

        System.out.printf("#%02x%02x%02x%n", 255, 255, 255);
        System.out.printf("#%02x%02x%02x%n", 0, 0, 0);

        String n = "张sir";
        int a = 19;
        String address = "河南省郑州市科学大道99号"; //%s 小写  %S 大写
        String info = String.format("姓名：%S，年龄：%03d岁，家庭地址：%s。", n, a, address);
        System.out.println(info);


        System.out.println(Math.random());
        System.out.printf("%f %<.1f %<.2f %<.3f %<.4f %<.0f%n", Math.random());

        //格式化对齐 10右
        System.out.printf("%20s%n","jack");
        System.out.printf("%20s%n","an");
        System.out.printf("%-10s%n","james");

        //50字符中间
        System.out.printf("%22s%n","管理系统");
        System.out.printf("%23s%n","jack");



    }
}
